const list = document.querySelector(".scroll");
const listStyle = getComputedStyle(list);

function clone() {
    const firstElement = list.children[0];
    const newElement = firstElement.cloneNode(true);
    list.appendChild(newElement);
}

let currentIndex = 0;
const itemHeight = list.offsetHeight;
console.log(itemHeight)
function moveTo() {
    let from = currentIndex * itemHeight;
    currentIndex++;
    let to = currentIndex * itemHeight;
    const duration = 1000;
    let durationTime = 10;
    const times = duration / durationTime;
    const dis = (to - from) / times;
    console.log(dis)
    let timerId = setInterval(() => {
        from += dis;
        // console.log(from)
        if (from >= to) {
            clearInterval(timerId);
            if (currentIndex === list.children.length - 1) {
                from = 0;
                currentIndex = 0;
            }
        }
        list.scrollTop = from;
    }, durationTime)
}

function init() {
    clone();
    setInterval(moveTo, 2000);
}

init();